package GUI;

import javax.swing.table.AbstractTableModel;

public class SonnyTableModel extends AbstractTableModel
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String[] columnNames;
    private Object[][] data;
    
    public SonnyTableModel(String[] columnNames, Object[][] data)
	{
		this.columnNames = columnNames;
		this.setData(data);
	}
    
	@Override
	 public int getColumnCount() {
	        return columnNames.length;
	    }

	@Override
    public int getRowCount() {
	        return getData().length;
	    }

	@Override
    public String getColumnName(int col) {
	        return columnNames[col];
	    }

	@Override
    public Object getValueAt(int row, int col) 
	{
			Object returnObj = null;
			if(getData().length > row)
			{
				if(getData()[row].length > col)
				{
					returnObj = getData()[row][col]; 
				}
			}
	        return returnObj;
	    }

	public void setData(Object[][] data) {
		this.data = data;
	}

	public Object[][] getData() {
		return data;
	}
	
}
